#include "synwit_ui_framework/synwit_ui.h"
#include "appkit/screen_id.h"
#include "appkit/screens/screen002.h"
#include "swm34s/common/lcdc/dev_lcdc.h"
#include "SWM341_sfc.h"
#include "SWM341.h"
/*
 * 界面回调函数
 */
static void screen002_on_timer(void *user_data)
{
    /* 界面定时器回调函数 */
	if(!DX_flag)
	{
		synwit_ui_load_screen(SCREEN001);
	}
	
	if(vision_delay_flag)
	{
		if(sound_state==0)
				PWM_Stop(PWM1_MSK);
		//printf("---vision_delay_count : %d\r\n", vision_delay_count);
		vision_delay_count++;
		if(vision_delay_count>=24)//延时3秒
		{
			vision_delay_count = 0;
			vision_delay_flag = false;
			
			vision_state_temp = vision_state;
			show_flag = 1;
		}
	}
	
	if(vision_state_temp==0x03||vision_state_temp==0x04)
	{
		 if(shanshuo_flag)
		 {
			 shanshuo_flag = false;
		 }
		 else
		 {
			 shanshuo_flag = true;
		 }
		 show_flag = 1;
  }
}

static void screen002_start(synwit_id_t screen_id)
{
    /* 在界面被显示给用户前，这个接口会被调用。 */
		lv_obj_t *Pic;
		Pic = synwit_ui_find_lv_obj(WIDGET_IMAGE11);
		lv_obj_set_hidden(Pic, true); //hidden
		Pic = synwit_ui_find_lv_obj(WIDGET_IMAGE12);
		lv_obj_set_hidden(Pic, true); //hidden
	
		if(km_MPH_state==0)
				Pic = synwit_ui_find_lv_obj(WIDGET_IMAGE12);
		else
				Pic = synwit_ui_find_lv_obj(WIDGET_IMAGE11);
		lv_obj_set_hidden(Pic, false); 
    // 打开下面的注释可以为本界面开启一个每100ms触发一次的定时器
    synwit_ui_start_scr_timer(125, NULL);
}

static void screen002_stop(synwit_id_t screen_id)
{
    /* 准备切换到其它界面前，这个接口会被调用。 */
}


/*
 * 界面注册对象
 */
synwit_screen_callback_t screen002_cb_obj = {
    .on_screen_start = screen002_start,
    .on_screen_stop = screen002_stop,
    .on_screen_timer = screen002_on_timer,
};

